<template>
	<!-- <view>社区主页面</view> -->
	<view class="news">
		<view class="cha">
			<input class="uni-input" confirm-type="search" v-model="articleTitle" placeholder="键盘右下角按钮显示为搜索" />
			<button size="mini" type="primary" @click="getNews" plain>查询</button>
		</view>
		<news-item @itemClick="goContents" :list="newsList"></news-item>
	</view>
</template>

<script>
	import newsItem from '../../../components/news-item/news-item.vue'
	export default{
		data() {
			return {
				articleTitle:'',
				newsList: [],
			}
		},
		methods: {
			async getNews() {
				uni.request({
				    url: `http://localhost:7000/bbs/bbs/getArticleList/`, //接口地址。
				    data: {
				        articleTitle: this.articleTitle
				    },
					method:'POST',
				    success: (res) => {
				        console.log(res);
						this.newsList = res.data.data
						this.articleTitle = ''
				    }
				});
			},
			goContents(articleId) {
				console.log(articleId)
				uni.navigateTo({
					url:'../contents/index?articleId='+articleId
				})
			}
		},
		components:{"news-item":newsItem},
		onLoad() {
			this.getNews()
		}
	}
</script>

<style lang="scss">
	.cha{
		display: flex;
		.uni-input{
			width: 600rpx;
		}
	}
	.in{
		border: 2rpx solid red;
	}
</style>
